package dosgi.core.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

/**
 * Class which is responsible for creating new proxy's instances of given class.
 * 
 * @author Jaroslaw Janik
 */
public class ProxyCreator {

	/**
	 * Method which creates new instance of proxy.
	 * 
	 * @param clazz Class object of which proxy's instance is created.
	 * @param invocationHandler The invocation handler to dispatch method invocations to.
	 * @return New proxy instance with the specified invocation handler.
	 */
	public static Object newInstance(Class<?> clazz, InvocationHandler invocationHandler) {
		return Proxy.newProxyInstance(clazz.getClassLoader(), new Class[] { clazz }, invocationHandler);
	}
}
